package com.xzc.refactory.method.extractMethod.tempVariable;

import com.xzc.refactory.method.extractMethod.tempVariableNone.Order;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Enumeration;

public class usedBeforeTargetFunR {
    String _name = "abc";
    Collection<Order> _orderList = new ArrayList<>();

    void printOwing(double previousAmount) {
        Enumeration<Order> e = Collections.enumeration(_orderList);
        double outstanding = previousAmount * 1.2;

        //print banner
        printBanner();

        // calculate outstanding
        while (e.hasMoreElements()) {
            Order each = e.nextElement();
            outstanding += each.getAmount();
        }

        // print details
        printDetails(outstanding);
    }

    void printBanner() {
        System.out.println("***********************");
        System.out.println("******* Customer Owes ***************");
        System.out.println("***********************");
    }

    //如果参数是对象，而此函数没有对其进行赋值，就可以这么做
    void printDetails(double outstanding) {
        System.out.println("name:" + _name);
        System.out.println("amount" + outstanding);
    }
}
